package com.xiyun.vod.controller;

import com.xiyun.common.response.result.R;
import com.xiyun.vod.service.VodService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@CrossOrigin
@Api(description = "课程视频上传")
@RestController
@RequestMapping("/xiyun/vod/video")
public class VodController {

    @Autowired
    private VodService vodService;

    @ApiOperation("上传视频")
    @PostMapping("uploadVideo")
    public R uploadVideoInfo(MultipartFile file){
        String videoId = vodService.uploadVideo(file);
        return R.ok().data("videoId",videoId);
    }

    @ApiOperation("根据视频id删除视频")
    @DeleteMapping("delVideo/{videoId}")
    public R delVideoInfo(@PathVariable String videoId){
        String s = vodService.delVideo(videoId);
        return R.ok().message(s);
    }

    @ApiOperation("删除多个云端视频")
    @DeleteMapping("deleteVideos")
    public R deleteVideosBatch(@RequestParam("videoIdList") List<String> videoIdList){
        vodService.delVideosBatch(videoIdList);
        return R.ok();
    }
}
